const mongoose = require('mongoose')
const Schema = mongoose.Schema
// 存储文章信息的集合
const bannerCollection = new Schema(
  {
    //标题
    midImg: { type: String, required: true },
    bigImg: { type: String, required: true },
    title: { type: String, required: true },
    description: { type: String, required: true },
    active: { type: Boolean, required: true },
  },
  {
    toJSON: { virtuals: true, getters: true },
  }
)

// bannerCollection.set('toJSON', {
//   transform: function(doc, ret) {
//     // 删除_id
//     delete ret._id;
//     // 添加id
//     ret.id = doc._id;
//   }
// });

const Banner = mongoose.model('Banner', bannerCollection)

module.exports = Banner
